<template>
  <div>
    <el-submenu :index="route.path" v-if="route.children && route.children.length > 0">
      <template slot="title">
        <i :class="`iconfont ${route.meta.icon} icon`"></i>
        <span>{{ generateTitle(route.meta.title) }}</span>
      </template>
      <sidebar-menu
        v-for="item in route.children"
        :key="item.path"
        :route="item"
      ></sidebar-menu>
    </el-submenu>
    <el-menu-item :index="route.path" v-else>
      <i :class="`iconfont ${route.meta.icon} icon`"></i>
      <span slot="title">{{ generateTitle(route.meta.title) }}</span>
    </el-menu-item>
  </div>
</template>

<script>
import {generateTitle} from "../../utils/i18n"
export default {
  name: "SidebarMenu",
  props: {
    route: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {};
  },
  mounted() {

  },
  methods: {
    generateTitle,
  },
};
</script>

<style scoped lang='scss'>
.icon{
  font-size: 18px;
  margin-right: 20px;
}
</style>
